package cn.pzhu.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.jasper.tagplugins.jstl.core.If;

import cn.pzhu.pojo.User;

/**
 * Servlet Filter implementation class F1Filter
 */
@WebFilter("/modify")
public class ModifyFilter extends HttpFilter {
	private static final long serialVersionUID = 1L;
	@Override
		protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
				throws IOException, ServletException {
			// TODO Auto-generated method stub
		User user = (User)req.getSession().getAttribute("user");
		if(!user.getUsername().equals(req.getParameter("username"))){
			res.setContentType("text/html");
			res.getWriter().print("<script>alert('禁止修改他人信息');location.href='index.jsp';</script>");
		}else {
			super.doFilter(req, res, chain);
		}
	}
}
